package com.uroad.liaoningpos.common;

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;

import com.tencent.bugly.crashreport.CrashReport;
import com.uroad.liaoningpos.R;
import com.uroad.liaoningpos.database.DaoUtils;
import com.uroad.liaoningpos.webService.BaseWS;
import com.uroad.lib.data.Constant;

/**
 * @创建者 wlw
 * @创建时间 2019/4/3 11:27
 * @描述 application
 */
public class CurrApplication extends Application {
    public static DaoUtils daoUtils;

    @Override
    public void onCreate() {
        super.onCreate();
        initWebservice();
        initDataBase();
        initBugly();
    }

    private void initBugly() {
        CrashReport.initCrashReport(getApplicationContext(), getResources().getString(R.string.bugly_appid), false);
    }

    private void initDataBase() {
        daoUtils = new DaoUtils(this);
    }

    //配置接口访问地址
    private void initWebservice() {
        if (GlobalData.isDebug) {
            Constant.BASE_URL = BaseWS.BASE_URL;
        } else {
            Constant.BASE_URL = BaseWS.BASE_URL;
        }
    }


    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
